﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 窗口切换工具
{
    public partial class _MsgBox : Form
    {
        public _MsgBox()
        {
            InitializeComponent();
        }

        private void _MsgBox_Load(object sender, EventArgs e)
        {

        }

        public static DialogResult ShowDialog(String UI_Text)
        {
            var _msgbox = new _MsgBox();
            _msgbox.StartPosition = FormStartPosition.Manual;
            _msgbox.Location = new Point( 150, 180);
            _msgbox.UI_TEXT.Text = UI_Text;
            _msgbox.TopMost = true;
            _msgbox.Show();
            Stopwatch sw = new Stopwatch();
            sw.Start();
            while (true)
            {
                Application.DoEvents();
                Thread.Sleep(100);
                if (sw.ElapsedMilliseconds > 800)
                {
                    _msgbox.Close();
                    break;
                }
            }

            return DialogResult.OK;
        }

        private void BtnConfirm_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void UI_TEXT_Click(object sender, EventArgs e)
        {

        }
    }
}
